package piwan;

import java.awt.event.MouseEvent;

import javax.media.opengl.GLCanvas;

import org.fenggui.Display;
import org.fenggui.binding.render.jogl.EventBinding;
import org.fenggui.event.mouse.MouseButton;

public class ConsumerBinding extends EventBinding {
	private Display display;
	public ConsumerBinding(GLCanvas c, Display d) {
		super(c,d);
		display = d;
	}
	
	public void mousePressed( MouseEvent e ) {
		if(e.getButton() == MouseEvent.BUTTON1) {
			if( display.fireMousePressedEvent(e.getX(), display.getHeight() - e.getY(), MouseButton.LEFT, e.getClickCount()) )
				e.consume();
		} else
			super.mousePressed(e);	
	}
	
	public void mouseReleased( MouseEvent e ) {
		if(e.getButton() == MouseEvent.BUTTON1) {
			if( display.fireMouseReleasedEvent(e.getX(), display.getHeight() - e.getY(), MouseButton.LEFT, e.getClickCount()) )
				e.consume();
		} else
			super.mouseReleased(e);	
	}
	
	public void mouseClicked( MouseEvent e ) {
		if(e.getButton() == MouseEvent.BUTTON1) {
			if( display.fireMouseClickEvent(e.getX(), display.getHeight() - e.getY(), MouseButton.LEFT, e.getClickCount()) )
				e.consume();
		} else
			super.mouseClicked(e);
	}

}
